package dhm.com.hpx.activity;

import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import dhm.com.hpx.R;
import dhm.com.hpx.base.BaseActivity;

public class FollowActivity extends BaseActivity {

    @BindView(R.id.ticker_progress)
    ProgressBar tickerProgress;
    @BindView(R.id.ticket_wb)
    WebView ticketWb;

    @Override
    protected int getLayout() {
        return R.layout.activity_follow;
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);

        String url = getIntent().getStringExtra("url");

        WebSettings webSettings = ticketWb.getSettings();
        webSettings.setUseWideViewPort(true);//是否支持双击缩放网页操作(wap网页不支持)
        webSettings.setJavaScriptEnabled(true);//是否支持JavaScript



        ticketWb.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                //设置加载进度条
                view.setWebChromeClient(new WebChromeClient() {
                    @Override
                    public void onProgressChanged(WebView view, int progress) {
                        if (tickerProgress != null) {
                            tickerProgress.setProgress(progress);
                            if (progress == 100) {
                                tickerProgress.setVisibility(View.GONE);
                            }else {
                                tickerProgress.setVisibility(View.VISIBLE);
                            }
                        }
                        super.onProgressChanged(view, progress);
                    }
                });
                return true;

            }
        });

        //加载网页
            ticketWb.loadUrl(url);
    }

    @Override
    protected void initData() {

    }
}
